﻿Imports csfnet2.Options

Friend Interface IMySQL_Connections

    '####################################################'
    '# Koneksi MySQL ini disesuaikan dengan             #'
    '# Referensi dari ConnectionStrings.com             #'
    '# Alamat : http://www.connectionstrings.com/mysql/ #'
    '####################################################'

#Region "MySQL Connector/Net"
    '###########################################################'
    '# Type         : .NET Framework Class Library             #'
    '# Usage        : MySql.Data.MySqlClient.MySqlConnection   #'
    '# Manufacturer : MySQL                                    #'
    '# http://www.mysql.com/downloads/connector/net/           #'
    '###########################################################'

    Function MySQL_ODBC51_Standard(ByVal ServerAddress As String, ByVal Username As String, ByVal Password As String, ByVal Database As String) As String
    Function MySQL_NET_InactivatingPreparedStatement(ByVal ServerAddress As String, ByVal Username As String, ByVal Password As String, ByVal Database As String, ByVal IgnorePrepare As Options.IgnorePrepare) As String
    Function MySQL_NET_NamedPipes(ByVal ServerAddress As String, ByVal Username As String, ByVal Password As String, ByVal Database As String)
    Function MySQL_NET_NetworkProtocol(ByVal ServerAddress As String, ByVal Port As Integer, ByVal Username As String, ByVal Password As String, ByVal Database As String, ByVal Protocol As Options.Protocol) As String
    Function MySQL_NET_Standard(ByVal ServerAddress As String, ByVal Username As String, ByVal Password As String, ByVal Database As String) As String
    Function MySQL_NET_SpecifyingCharacterSet(ByVal ServerAddress As String, ByVal Username As String, ByVal Password As String, ByVal Database As String, ByVal CharSet As Options.CharSet) As String
    Function MySQL_NET_SpecifyingCommandTimeout(ByVal ServerAddress As String, ByVal Port As Integer, ByVal Username As String, ByVal Password As String, ByVal Database As String, ByVal Timeout As Integer) As String
    Function MySQL_NET_SpecifyingConnectionTimeout(ByVal ServerAddress As String, ByVal Port As Integer, ByVal Username As String, ByVal Password As String, ByVal Database As String, ByVal Timeout As Integer) As String
    Function MySQL_NET_SpecifyingPort(ByVal ServerAddress As String, ByVal Port As Integer, ByVal Username As String, ByVal Password As String, ByVal Database As String) As String
    Function MySQL_NET_SpecifyingSharedMemoryName(ByVal ServerAddress As String, ByVal Username As String, ByVal Password As String, ByVal Database As String, ByVal SharedMemoryName As Options.SharedMemoryName) As String
    Function MySQL_NET_UsingEncryption(ByVal ServerAddress As String, ByVal Username As String, ByVal Password As String, ByVal Database As String, ByVal Encryption As Options.Encryption) As String
    Function MySQL_NET_UsingEncryptionAlternative(ByVal ServerAddress As String, ByVal Username As String, ByVal Password As String, ByVal Database As String, ByVal Encrypt As Options.Encrypt) As String
#End Region

#Region "eInfoDesigns.dbProvider"
    '########################################################################'
    '# Type         : .NET Framework Class Library                          #'
    '# Usage        : eInfoDesigns.dbProvider.MySqlClient.MySqlConnection   #'
    '# Manufacturer : eInfoDesigns                                          #'
    '#                                                                      #'
    '########################################################################'

    Function eInfoDesign_Standard(ByVal ServerAddress As String, ByVal Username As String, ByVal Password As String, ByVal Database As String) As String
#End Region

#Region "dotConnect for MySQL"
    '###########################################################'
    '# Type         : .NET Framework Class Library             #'
    '# Usage        : Devart.Data.MySql.MySqlConnection        #'
    '# Manufacturer : Devart                                   #'
    '# http://www.devart.com/dotconnect/mysql/                 #'
    '###########################################################'

    Function Devart_Standard(ByVal ServerAddress As String, ByVal Username As String, ByVal Password As String, ByVal Database As String, ByVal Port As Integer, ByVal Direct As Boolean, ByVal Protocol As String, ByVal Compress As Options.Compress, ByVal Pooling As Boolean, ByVal MinPoolSize As Integer, ByVal MaxPoolSize As Integer, ByVal ConnectionLivetime As Integer) As String
#End Region

#Region "MySQLDriverCS"
    '###########################################################'
    '# Type         : .NET Framework Class Library             #'
    '# Usage        : MySQLDriverCS.MySQLConnection            #'
    '# Manufacturer : MySQLDriverCS project team               #'
    '# http://sourceforge.net/projects/mysqldrivercs/          #'
    '###########################################################'

    Function MySQLDriverCS_Standard(ByVal ServerAddress As String, ByVal Username As String, ByVal Password As String, ByVal Database As String, ByVal Port As Integer) As String
#End Region

#Region ".NET Framework Data Provider for OLEDB"
    '###########################################################'
    '# Type         : .NET Framework Wrapper Class Library     #'
    '# Usage        : System.Data.OleDb.OleDbConnection        #'
    '# Manufacturer : Microsoft                                #'
    '###########################################################'

    Function Microsoft_OLEDB_Standard(ByVal Database As String, ByVal Username As String, ByVal Password As String) As String
#End Region

#Region ".NET Framework Data Provider for MySQL Connector/ODBC 5.1"
    '###########################################################'
    '# Type         : .NET Framework Wrapper Class Librar      #'
    '# Usage        : System.Data.Odbc.OdbcConnection          #'
    '# Manufacturer : Microsoft                                #'
    '###########################################################'

    Function Microsoft_ODBC51_Standard(ByVal ServerAddress As String, ByVal Database As String, ByVal Username As String, ByVal Password As String) As String
#End Region

End Interface

''' <summary>
''' Class untuk mengambil nilai jenis koneksi dari database MySQL
''' </summary>
Public Class MySQL
    Implements IMySQL_Connections

    Public Function Devart_Standard(ServerAddress As String, Username As String, Password As String, Database As String, Port As Integer, Direct As Boolean, Protocol As String, Compress As Compress, Pooling As Boolean, MinPoolSize As Integer, MaxPoolSize As Integer, ConnectionLivetime As Integer) As String Implements IMySQL_Connections.Devart_Standard
        Select Case Compress
            Case Options.Compress.No
                _PARAM = "false"
            Case Options.Compress.Yes
                _PARAM = "true"
        End Select
        _RESULT = "Host=" & Trim(ServerAddress) & ";User ID=" & Trim(Username) & ";Password=" & Password & ";Database=" & Trim(Database) & ";Port=" & Port & ";Direct=" & Direct & ";Protocol=" & Trim(Protocol) & ";Compress=" & _PARAM & ";Pooling=" & Pooling & ";Min Pool Size=" & MinPoolSize & ";Max Pool Size=" & MaxPoolSize & ";Connection Lifetime=" & ConnectionLivetime & ";"
        Return _RESULT
    End Function

    Public Function eInfoDesign_Standard(ServerAddress As String, Username As String, Password As String, Database As String) As String Implements IMySQL_Connections.eInfoDesign_Standard
        _RESULT = "Data Source=" & Trim(ServerAddress) & ";Database=" & Trim(Database) & ";User ID=" & Trim(Username) & ";Password=" & Password & ";Command Logging=false;"
        Return _RESULT
    End Function

    Public Function Microsoft_ODBC51_Standard(ServerAddress As String, Database As String, Username As String, Password As String) As String Implements IMySQL_Connections.Microsoft_ODBC51_Standard
        _RESULT = "Driver={MySQL ODBC 5.1 Driver};Server=" & Trim(ServerAddress) & ";Database=" & Trim(Database) & "; User=" & Trim(Username) & ";Password=" & Password & ";Option=3;"
        Return _RESULT
    End Function

    Public Function Microsoft_OLEDB_Standard(Database As String, Username As String, Password As String) As String Implements IMySQL_Connections.Microsoft_OLEDB_Standard
        _RESULT = "Provider=MySQLProv;Data Source=" & Trim(Database) & ";User Id=" & Trim(Username) & ";Password=" & Password & ";"
        Return _RESULT
    End Function

    Public Function MySQL_NET_InactivatingPreparedStatement(ServerAddress As String, Username As String, Password As String, Database As String, IgnorePrepare As Options.IgnorePrepare) As String Implements IMySQL_Connections.MySQL_NET_InactivatingPreparedStatement
        Select Case IgnorePrepare
            Case Options.IgnorePrepare.No
                _PARAM = "false"
            Case Options.IgnorePrepare.Yes
                _PARAM = "true"
        End Select
        _RESULT = "Server=" & Trim(ServerAddress) & ";Database=" & Trim(Database) & ";Uid=" & Trim(Username) & ";Pwd=" & Password & ";Ignore Prepare=" & _PARAM & ";"
        Return _RESULT
    End Function

    Public Function MySQL_NET_NamedPipes(ServerAddress As String, Username As String, Password As String, Database As String) As Object Implements IMySQL_Connections.MySQL_NET_NamedPipes
        _RESULT = "Server=" & Trim(ServerAddress) & ";Port=-1;Database=" & Trim(Database) & ";Uid=" & Trim(Username) & ";Pwd=" & Password & ";"
        Return _RESULT
    End Function

    Public Function MySQL_NET_NetworkProtocol(ServerAddress As String, Port As Integer, Username As String, Password As String, Database As String, Protocol As Options.Protocol) As String Implements IMySQL_Connections.MySQL_NET_NetworkProtocol
        Select Case Protocol
            Case Options.Protocol.SOCKET
                _PARAM = "socket"
            Case Options.Protocol.TCP
                _PARAM = "tcp"
        End Select
        _RESULT = "Server=" & Trim(ServerAddress) & ";Database=" & Trim(Database) & ";Uid=" & Trim(Username) & ";Pwd=" & Password & "; Protocol=" & _PARAM & ";"
        Return _RESULT
    End Function

    Public Function MySQL_NET_SpecifyingCharacterSet(ServerAddress As String, Username As String, Password As String, Database As String, CharSet As Options.CharSet) As String Implements IMySQL_Connections.MySQL_NET_SpecifyingCharacterSet
        Select Case CharSet
            Case Options.CharSet.UTF8
                _PARAM = "utf8"
        End Select
        _RESULT = "Server=" & Trim(ServerAddress) & ";Database=" & Trim(Database) & ";Uid=" & Trim(Username) & ";Pwd=" & Password & ";CharSet=" & _PARAM & ";"
        Return _RESULT
    End Function

    Public Function MySQL_NET_SpecifyingCommandTimeout(ServerAddress As String, Port As Integer, Username As String, Password As String, Database As String, Timeout As Integer) As String Implements IMySQL_Connections.MySQL_NET_SpecifyingCommandTimeout
        _RESULT = "Server=" & Trim(ServerAddress) & ";Database=" & Trim(Database) & ";Uid=" & Trim(Username) & ";Pwd=" & Password & ";default command timeout=" & Timeout & ";"
        Return _RESULT
    End Function

    Public Function MySQL_NET_SpecifyingConnectionTimeout(ServerAddress As String, Port As Integer, Username As String, Password As String, Database As String, Timeout As Integer) As String Implements IMySQL_Connections.MySQL_NET_SpecifyingConnectionTimeout
        _RESULT = "Server=" & Trim(ServerAddress) & ";Database=" & Trim(Database) & ";Uid=" & Trim(Username) & ";Pwd=" & Password & ";Connection Timeout=" & Timeout & ";"
        Return _RESULT
    End Function

    Public Function MySQL_NET_SpecifyingPort(ServerAddress As String, Port As Integer, Username As String, Password As String, Database As String) As String Implements IMySQL_Connections.MySQL_NET_SpecifyingPort
        _RESULT = "Server=" & Trim(ServerAddress) & ";Database=" & Trim(Database) & ";Uid=" & Trim(Username) & ";Pwd=" & Password & ";Port=" & Port & ";"
        Return _RESULT
    End Function

    Public Function MySQL_NET_SpecifyingSharedMemoryName(ServerAddress As String, Username As String, Password As String, Database As String, SharedMemoryName As Options.SharedMemoryName) As String Implements IMySQL_Connections.MySQL_NET_SpecifyingSharedMemoryName
        Select Case SharedMemoryName
            Case Options.SharedMemoryName.MYSQL
                _PARAM = "MYSQL"
        End Select
        _RESULT = "Server=" & Trim(ServerAddress) & ";Database=" & Trim(Database) & ";Uid=" & Trim(Username) & ";Pwd=" & Password & ";Shared Memory Name=" & _PARAM & ";"
        Return _RESULT
    End Function

    Public Function MySQL_NET_Standard(ServerAddress As String, Username As String, Password As String, Database As String) As String Implements IMySQL_Connections.MySQL_NET_Standard
        _RESULT = "Server=" & Trim(ServerAddress) & ";Database=" & Trim(Database) & ";Uid=" & Trim(Username) & ";Pwd=" & Password & ";"
        Return _RESULT
    End Function

    Public Function MySQL_NET_UsingEncryption(ServerAddress As String, Username As String, Password As String, Database As String, Encryption As Options.Encryption) As String Implements IMySQL_Connections.MySQL_NET_UsingEncryption
        Select Case Encryption
            Case Options.Encryption.No
                _PARAM = "false"
            Case Options.Encryption.Yes
                _PARAM = "true"
        End Select
        _RESULT = "Server=" & Trim(ServerAddress) & ";Database=" & Trim(Database) & ";Uid=" & Trim(Username) & ";Pwd=" & Password & ";Encryption=" & _PARAM & ";"
        Return _RESULT
    End Function

    Public Function MySQL_NET_UsingEncryptionAlternative(ServerAddress As String, Username As String, Password As String, Database As String, Encrypt As Options.Encrypt) As String Implements IMySQL_Connections.MySQL_NET_UsingEncryptionAlternative
        Select Case Encrypt
            Case Options.Encrypt.No
                _PARAM = "False"
            Case Options.Encrypt.Yes
                _PARAM = "True"
        End Select
        _RESULT = "Server=" & Trim(ServerAddress) & ";Database=" & Trim(Database) & ";Uid=" & Trim(Username) & ";Pwd=" & Password & ";Encrypt=" & _PARAM & ";"
        Return _RESULT
    End Function

    Public Function MySQL_ODBC51_Standard(ServerAddress As String, Username As String, Password As String, Database As String) As String Implements IMySQL_Connections.MySQL_ODBC51_Standard
        _RESULT = "Driver={MySQL ODBC 5.1 Driver};Server=" & Trim(ServerAddress) & ";Database=" & Trim(Database) & "; User=" & Trim(Username) & ";Password=" & Password & ";Option=3;"
        Return _RESULT
    End Function

    Public Function MySQLDriverCS_Standard(ServerAddress As String, Username As String, Password As String, Database As String, Port As Integer) As String Implements IMySQL_Connections.MySQLDriverCS_Standard
        _RESULT = "Location=" & Trim(ServerAddress) & ";Data Source=" & Trim(Database) & ";User ID=" & Trim(Username) & ";Password=" & Password & ";Port=" & Port & ";Extended Properties="""";"
        Return _RESULT
    End Function

End Class
